/**
 * 工位管理-删除工位（空闲状态下）
 */
import React, { memo } from 'react';
import { withRouter } from 'umi';
import AuthComponent from '@/utils/auth/AuthComponent';
import { Popconfirm, message } from 'antd';
import Icon from '../Icon';
import { handleDeleteStation } from '../../service';

function RelativeEmployee({ onRefresh, info }) {
    const handleConfirm = async () => {
        try {
            const { code, msg } = await handleDeleteStation(info.id);
            if (code === 10000) {
                message.success('删除成功！');
                onRefresh();
            } else {
                message.error(msg);
            }
        } catch (e) {
            message.error(e);
        }
    };
    return (
        <AuthComponent code="office:administration:adminManage:station:delete">
            <Popconfirm
                title="你确定要删除该工位吗？"
                onConfirm={ handleConfirm }
            >
                <Icon
                    type="DeleteIcon"
                    title="删除"
                />
            </Popconfirm>
        </AuthComponent>
    );
}
export default withRouter(memo(RelativeEmployee));
